package com.lovo.ssc.config;

import com.lovo.sscsys.util.SSCSYSMQUtil;
import com.lovo.util.MQUtil;
import org.springframework.amqp.core.*;
import org.springframework.amqp.rabbit.connection.CachingConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Auther: 张海军
 * @Date: 2022/7/19
 */
@Configuration
public class BuyPlanMQConfig {
    @Autowired
    CachingConnectionFactory connectionFactory2;
    //rabbitmq模板
    @Bean(value = "rabbitTemplate2")
    public RabbitTemplate rabbitTemplate2(){
        return new RabbitTemplate(connectionFactory2);
    }

//ss
    @Bean
    public Queue buyPlanQueue(){
        return new Queue(SSCSYSMQUtil.buyPlanQueue);
    }
    @Bean
    public DirectExchange directExchangeBuyPlan(){
        return new DirectExchange(SSCSYSMQUtil.directExchangeBuyPlan);
    }
    @Bean
    public Binding directExchangeBuyPlanTobuyPlanQueue(Queue buyPlanQueue,DirectExchange directExchangeBuyPlan){
        return BindingBuilder.bind(buyPlanQueue).to(directExchangeBuyPlan).with(SSCSYSMQUtil.buyPlanKey);
    }

}
